﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.Enum;
using TodoApp.GoodsModel;
using TodoApp.LiveShopCarDTO;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  购物车 实现接口 
    /// </summary>
    public class CarService : Volo.Abp.Application.Services.ApplicationService, ICarService
    {
        
        private readonly IRepository<LiveShopCar, int> _liveShopCars;
        public CarService(IRepository<LiveShopCar, int> liveShopCars) {
            _liveShopCars = liveShopCars;
        }
        
        /// <summary>
        ///  删除 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task DeleteAsync(int id)
        {
            await _liveShopCars.DeleteAsync(id);
        }
        /// <summary>
        ///  显示 
        /// </summary>
        /// <returns></returns>
        public async Task<List<LiveShopCarShowDTO>> GetListAsync()
        {
            return ObjectMapper.Map<List<LiveShopCar>, List<LiveShopCarShowDTO>>(await _liveShopCars.GetListAsync());
        }
        /// <summary>
        /// 添加 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public async Task<ShopStatus> InsertAsync(LiveShopCarAddDTO model)
        {
            await _liveShopCars.InsertAsync(ObjectMapper.Map<LiveShopCarAddDTO, LiveShopCar>(model));
            return ShopStatus.Succeed;
        }
        /// <summary>
        /// 修改 
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public  Task<ShopStatus> UpdateAsync(LiveShopCarShowDTO model)
        {
            throw new NotImplementedException();
        }
    }
}
